import {infoLog, warnLog} from "../../src/utils";
import {App} from "./src/App";
import {Scene} from "./src/Scene";

import axios from 'axios';
import {parseObj} from "../../src/utils/objParser";
import {Cache} from "../../src/ds/caches";
import {Shader} from "./src/Shader";
import {IMeshData} from "../../src/utils/MeshData";
import {initLineShader} from "./src/shaders/lineShader";
import {Quat, Vec3} from "../../src/math";
import {Bone} from "./src/skeletal";

infoLog("hello world!");

// 创建一堆的cache
let shaderCache = new Cache<Shader>();
let meshCache = new Cache<IMeshData>();

const Width = 800;
const Height = 600;
let app: App;
window.onload = function () {

    axios.get('assets/ball.obj').then((res) => {
        let objStr = res.data;
        let meshData = parseObj(objStr);
        infoLog(meshData);
    }).catch((e) => {
        console.log('load assets/ball.obj failed!');
    })

    app = new App(Width, Height);

    // 将使用到的shader都加载进来
    let lineShader = initLineShader();
    shaderCache.set('line', lineShader);
    app.shaderCache = shaderCache

    let scene = new Scene();
    app.startWithScene(scene);
}






